#pragma once

#include "Controller.h"

#include <boost/signal.hpp>

#include "../domain/models/Card.h"
#include "../domain/models/CardSet.h"
#include "../domain/models/CardsCollection.h"
#include "../domain/models/Player.h"
#include "../views/abstract/IDeductionView.h"

namespace Controllers {
	class DeductionController: public Controller
	{
		Views::IDeductionView* view;
		Cards::CardSet searched_cards;
		Players::Player* current_player;
		Players::PlayersQueue players;
		Cards::CardsCollection cards;
		Cards::Card* deducted_card;
		
		boost::signal<void ()> onSearchedCardsChange;
		boost::signal<void ()> onDeductedCardChange;
		boost::signal<void ()> deductionEndEvent;

		void askCurrentPlayerForSearchedCards();
		void askPlayersForSearchedCards(Cards::Card** found_card, Players::Player** found_card_owner);
		Cards::RoomCard* findActualRoom();

		void setSearchedCards(Cards::PlayerCard*, Cards::WeaponCard*);
		void askOtherPlayersForSearchedCards();
		void askNextPlayerForSearchedCards();
		void setDeductedCard(Cards::Card*);
		void cardFound();

	public:
		boost::signal<void ()> deductionPerformedEvent;

		DeductionController(Players::Player*, Players::PlayersQueue, Cards::CardsCollection);

		void perform();
	};

}

